﻿using FastCloud.Base.Desgin;
using FastCloud.ORG.Entity;
using FastIOC.Attribute;
using FastORM.Entity;
using FastUtil.Data;
using System;
using System.Collections.Generic;
using System.Text;

namespace FastCloud.ORG.DB
{
    public class DB_UserJob : BaseDBML<Frame_UserJob>
    {
       [AutoWired]
        private DB_UserJobSetting DB_UserJobSetting;
        public override void Insert(Frame_UserJob Entity)
        {
            if (string.IsNullOrEmpty(Entity.RelationGuid))
            {
                Entity.RelationGuid = GenerateUtil.GenerateUnitGuid();
                Entity.AddDate = DateTime.Now;
            }
            base.Insert(Entity);
        }

        public bool CheckExistUserJob(string UserGuid)
        {
            return SelectCount("UserGuid=@UserGuid", new List<ParamEntity>() { new ParamEntity() { ParamName = "UserGuid", ParamValue = UserGuid } }) > 0;
        }

        public override void DeleteByID(string UnitGuid)
        {
            base.DeleteByID(UnitGuid);
            DB_UserJobSetting.DeleteByUserGuid(UserGuid);
        }
    }
}
